#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
  void wiggleSort(vector<int> &nums) {
    std::sort(nums.begin(), nums.end());
    vector<int> res;
    res.resize(nums.size());
    int pos = 0;
    for (int i = 0; i < res.size(); i += 2) {
      res[i] = nums[pos];
      pos++;
    }
    for (int i = 1; i < res.size(); i += 2) {
      res[i] = nums[pos];
      pos++;
    }
    nums = res;
  }
};

int main() {
  vector<int> a = {1,3,2,2,3,1};
  Solution s;
  s.wiggleSort(a);
  for (auto q = a.begin(); q != a.end(); ++q) {
    cout << *q << " ";
  }
  cout << endl;
  return 0;
}
